//
//  ZHIMClient.h
//  ZHIMKit
//
//  Created by Chen Zhangli on 2021/1/12.
//

#import <Foundation/Foundation.h>
#import "ZHIMConfig.h"
#import "ZHIMClientDelegate.h"
#import "IZHIMContactManager.h"
#import "IZHIMChatManager.h"
#import "IZHIMGroupManager.h"
#import "IZHIMCustomerServiceManager.h"
#import "IZHIMOfficialManager.h"

NS_ASSUME_NONNULL_BEGIN

@interface ZHIMClient : NSObject

/// 通讯核心单例
+ (instancetype)sharedClient;


/// SDK版本号
@property (nonatomic, strong, readonly) NSString *version;

/// 初始化SDK
/// @param appKey 从开发者平台创建应用后获取到的AppKey
- (void)initWithAppKey:(NSString *)appKey;

/// 初始化SDK
/// @param config 配置项
- (void)initWithConfig:(ZHIMConfig *)config;

/// 设置deviceToken，用于远程推送
/// @param deviceToken 从系统获取到的设备deviceToken
- (void)setDeviceToken:(NSData *)deviceToken;


/// 当前登录账号
@property (nonatomic, strong, readonly) NSString *currentUsername;
@property (nonatomic, strong, readonly) ZHIMUser *currentUser;
@property (nonatomic, strong, readonly) NSString *currentToken;

/// 聊天
@property (nonatomic, strong, readonly) id<IZHIMChatManager> chatManager;


/// 好友
@property (nonatomic, strong, readonly) id<IZHIMContactManager> contactManager;


/// 群组
@property (nonatomic, strong, readonly) id<IZHIMGroupManager> groupManager;


/// 客服
@property (nonatomic, strong, readonly) id<IZHIMCustomerServiceManager> csManager;

/// 公众号
@property (nonatomic, strong, readonly) id<IZHIMOfficialManager> officialManager;


/// 添加回调代理
/// @param delegate 要添加的代理
- (void)addDelegate:(id<ZHIMClientDelegate>)delegate;


/// 移除回调代理
/// @param delegate 要移除的代理
- (void)removeDelegate:(id<ZHIMClientDelegate>)delegate;


/// 密码登录
/// @param username 用户名
/// @param password 登录密码
/// @param completion 登录完成的回调
- (void)loginWithUsername:(NSString *)username
                 password:(NSString *)password
               completion:(void (^)(NSString *username, NSError *error))completion;


/// token登录
/// @param username 用户名
/// @param token Token
/// @param completion 登录完成的回调
- (void)loginWithUsername:(NSString *)username
                    token:(NSString *)token
               completion:(void (^)(NSString *username, NSError *error))completion;


/// 退出登录
/// @param completion 退出登录的回调
- (void)logout:(void (^)(NSError *error))completion;

@end

NS_ASSUME_NONNULL_END
